/* Copyright 2017, 2018, 2019, 2020 Gabriel Czernikier
 *
 * This file is part of Côtehaus.
 * Côtehaus is free software: you can redistribute it and/or modify
 * it under the terms of one of the following:
 * 1. The same dual license as that of Côtehaus itself, of which individual licenses are
 * the MIT License and the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 2. The MIT License.
 * 3. The GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * Côtehaus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * MIT License and the GNU General Public License for more details.
 * You should have received a copy of the MIT License and the GNU General Public License
 * along with Côtehaus.  If not, see <https://opensource.org/licenses/MIT> and <http://www.gnu.org/licenses/>.
 */
#ifndef __CH_CLASS_DEF_H
#define __CH_CLASS_DEF_H

#include <stdbool.h>
#include <stdlib.h>
#include "lgwseq.h"
#include "types.h"

/* class_def. Synopsis/API usage outline:
 * A Class or Interface declaration synthesyses a qualified RefType, as is the case for stanzas "package bar" and "public class Foo". Then, it would be handled as follows:
 * type_id = add_type_id(qualified RefType) // add_type_id defined in "type.c"
 * class_def = class_def_new(type_id...)
 * A Class or Interface declaration occurs in a place in which a nested type is constitued, esquematicaly resumed in "class A { class B {} }". A typical handling for that case is as follows:
 * stack_push(&class_def->nesting_stack, &class_nesting_stack_head) // stack_push function defined in types.h
 * type_id = add_type_id(qualified RefType)
 * class_def = class_def_new(type_id...)
 * When the nesting context closes, a handling like the following is suitable:
 * stack_pop(class_def, class_nesting_stack_head, struct class_def_st, nesting_stack) // stack_pop defined in types.h
 */
struct class_def_st {
	struct type_id_st *clstyp;   // class type
	struct type_id_st *parenttyp;   // parent class type
	struct type_list_st *parent_iface;   // parent interfaces, elements of type struct type_id_st*
	struct class_data_st *class_data;
	struct list_head clsdef_lst;   // the list this item is a member of
	struct oclass_def *cotehaus_oclass_def;
	bool external;
	struct list_head cotehaus_method_head;  // owned methods, used for method search
	struct list_head cotehaus_field_head;  // owned fields, used for field search
	struct ofield_id_search_st *ofield_id;  // field search's 2nd. phase
	struct omethod_id_search_st *omethod_id;   // method search's 2nd. phase
};

struct class_def_st *add_class_def(struct type_id_st *clstyp, bool external);

#endif
